<template>
  <ul class="cardStyle">
    <!-- <li class="table-head">
      <span v-for="item in tableColumns" :key="item.key" :class="[item.scopedSlots ? `flex-span${item.scopedSlots}` : '', 'font-size14']">
        {{ item.title }}
      </span>
    </li> -->
    <Vue3SeamlessScroll :list="dataList" :visibleCount="8" :hover="true" :singleHeight="39" :singleWaitTime="waitTime" :singleLine="true">
      <li v-for="(item, index) in dataList" :key="keys || index">
        <template v-for="item1 in tableColumns" :key="item1.key">
          <span :class="item1.scopedSlots ? `flex-span${item1.scopedSlots}` : ''" :title="item[item1['key']]">
            <slot :name="item1.key" :data="item[item1['key']]" :itemData="item">{{ item[item1['key']] || '--' }} </slot>
          </span>
        </template>
      </li>
    </Vue3SeamlessScroll>
  </ul>
</template>
<script lang="ts" name="table-scroll" setup>
  import { computed, PropType, reactive } from 'vue';
  import { Vue3SeamlessScroll } from 'vue3-seamless-scroll';
  //#region 模拟
  // const tableColumnsWarning = [
  //   {
  //     title: '时间',
  //     key: 'sj',
  //     scopedSlots: 2 // 所占宽度
  //   },
  //   {
  //     title: '类型',
  //     key: 'lx',
  //     scopedSlots: 1
  //   },
  //   {
  //     title: '地址',
  //     key: 'dz',
  //     scopedSlots: 3
  //   },
  //   {
  //     title: '事件',
  //     key: 'sjxq',
  //     scopedSlots: 2
  //   },
  //   {
  //     title: '操作',
  //     key: 'cz'
  //   }
  // ]
  //#endregion

  const props = defineProps({
    info: {
      type: Array as PropType<any[]>,
      default: () => {
        return [];
      },
    },
    loading: {
      type: Boolean,
      default: false,
    },
    tableColumns: {
      type: Array as PropType<any[]>,
      default: () => {
        return [];
      },
    },
    keys: {
      type: String || Number,
      default: '',
    },
    num: { type: Number, default: 8 },
    waitTime: {
      type: Number,
      default: 1000,
    },
  });

  // const scrollOption = computed(() => {
  //   return {
  //     step: 1,
  //     hoverStop: true,
  //     limitMoveNum: props.num,
  //     singleHeight: 34,
  //     waitTime: 2300,
  //   };
  // });
  const dataList = computed(() => {
    return props.info;
  });
</script>
<style lang="less" scoped>
  .cardStyle {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
  ul {
    height: 100%;
    padding: 0;
    margin: 0;

    li {
      padding: 0;
      list-style: none;
      font-size: 14px;
      line-height: 39px;
      display: flex;
      align-content: space-between;
      justify-content: left;
      align-items: center;
      border-bottom: 1px solid #e7e7e7;
      width: 100%;
      > span {
        flex: 1;
        display: inline-block;
        // display: -webkit-box;
        // display: -webkit-box-flex;
        color: rgba(0, 0, 0, 0.85);
        text-align: left;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        // -webkit-line-clamp: 1;
        // -webkit-box-orient: vertical;
      }
      > span.flex-span {
        display: flex;
        flex-direction: row;
      }
      > span.flex-span2 {
        flex: 2;
      }
      > span.flex-span3 {
        flex: 3;
      }
      > span.flex-span4 {
        flex: 4;
      }
      // > span:last-child {
      //   text-align: right;
      // }
    }
    // li:nth-child(even) {
    //   background: rgba(0, 102, 255, 0.08);
    //   //border: none !important;
    // }
    .table-head {
      // background: #0a377c;
      padding: 0;
      > span {
        -webkit-line-clamp: 2;
        color: rgba(102, 225, 252, 0.8);
        text-align: center;
      }
    }
  }
</style>
